<?php
namespace Admin\Controller;
use Think\Controller;
class OtherController extends CommonController {
	public function index()
	{
		$this->_page("Other",10,$order="create_time");
		$this->display();
	}
	//删除
	public function delete()
	{
		$name="Other";
	    $sid=I("post.sid");
		$this->_foreverdelete($name,$sid);
	}
	//修改
	public function update()
	{
		$name="Other";
		$this->_edit($name);
	}
	//信息修改
	public function edit()
	{
		$data['id']=I("post.id");
		$data['status']=I("post.status");
		$data['name']=I("post.name");
		$data['title']=$_POST['editorValue'];
		$name="Other";
		$model = D($name);
        // 更新数据
        $list = $model->save($data);
        if (false !== $list) {
            //成功提示
            $this->success('编辑成功!',cookie('_currentUrl_'));
        } else {
            //错误提示
            $this->error('编辑失败!');
        }

	}
	//修改
    public function insert()
	{
		if(!empty($_POST)){
		$data['name'] = I("post.name");
	    $data['status'] = I("post.status");
	    $data['title'] =$_POST['editorValue'];
	   $model = D("Other");
		        //保存当前数据对象
        $list = $model->add($data);
        if ($list !== false) { //保存成功
            $this->success('新增成功!',cookie('_currentUrl_'));
        } else {
            //失败提示
            $this->error('新增失败!');
        }
    }else{
		$this->display();  
    }
		   
  }

  		//修改状态
	public function other()
	{
		$data['id']=I("post.sid");
		$data['status']=I("post.sta");
		if (!empty($data)) {
			$Site=M("Other");
			$list=$Site->save($data);
			if ($list!=false) {
				$this->ajaxReturn('修改成功');
				
			}else{
				$this->ajaxReturn('修改失败');
			}
		}  
	}
}